{extend name="admin@index_layout"/}
{block name="main"}
<style>
    .layui-form-label {
        width: 130px !important;
    }

    .layui-form-item .layui-input-inline {
        width: 268px !important;
    }

    .item-upgrade .layui-input-inline, .item-ratio .layui-input-inline {
        width: 66px !important;
    }

    .number-input {
        text-align: center;
    }
</style>
<div class="layui-card">
    <div class="layui-card-body">
        <div class="layui-tab layui-tab-card">
            <div class="layui-tab-content">
                <form class="layui-form data-form" method="post" id="dataForm">
                    <input type="hidden" name="ids" value="{$ids}">
                    <div class="layui-form-item">
                        <label class="layui-form-label">商品分类</label>
                        <div class="layui-input-inline">
                            <select lay-search name="category_id" lay-filter="category_id">
                                <option value=""></option>
                                {volist name="category" key="k" id="vo"}
                                <option value="{$vo.id}">{$vo.name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">商品专区</label>
                        <div class="layui-input-inline">
                            <select lay-search name="type" lay-filter="type">
                                <option value=""></option>
                                {volist name="type" key="k" id="vo"}
                                <option value="{$vo.id}">{$vo.name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>



                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="formDataSubmit" target-form="data-form">提交
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script>
    layui.use(['element', 'form'], function () {
        var form = layui.form;
        form.on('submit(formDataSubmit)', function (data) {
            var url = '{:url("batch")}';
            $.post(url, $('.data-form').serialize()).success(function (res) {
                console.log(res);
                if (res.code === -1) {
                    layer.msg(res.msg, {icon: 2});
                    return false;
                }
                layer.msg(res.msg, {time: 1000}, function () {
                    parent.closeAllLayers(true)
                });
            });
            return false;
        });
        form.render();
    });
</script>

{/block}
